<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<html>
<head>
<title>
FlyUI Overview
</title>
<link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script>
function asd() {
	
		parent.document.title="flyted-imagewidget.js Overview";
	
}
</script>
</head>
<body bgcolor="white" onload="asd();">

<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> 	<font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top">
<em>
<b>FlyUI</b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<center>
	
	   <h2>flyted-imagewidget.js</h2>
	
</center>

	


<h4>Summary</h4>
<p>
	
		This script defines a widget for fetching and displaying images from www.fly-ted.org.
 <BR/><BR/><B>Version: </B>$Revision:538 $ on $Date: 2008-08-27 09:08:41 +0100 (Wed, 27 Aug 2008) $ by $Author: aliman $
 <BR/><BR/><B>Requires:</B><UL>- YAHOO.util.Connect<BR/>- <a href="../../flyui.html#">flyui</a><BR/>- <a href="../../flyui/flyted/Service.html#">flyui.flyted.Service</a><BR/>- <a href="../../flyui/flybase/Gene.html#">TODO license terms</a></UL><B>Author:</B> <a href="http://purl.org/net/aliman">Alistair Miles</a>, Graham Klyne, Jun Zhao
 <BR/>
	
</p>

<hr>


    <table border="1" cellpadding="3" cellspacing="0" width="100%">
    <tr bgcolor="#CCCCFF" class="TableHeadingColor">
    <td colspan=2><font size="+2">
    
        <b>Class Summary</b>
    
    </font></td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="flyui/flyted/ImageWidget.html">flyui.flyted.ImageWidget</a></b></td>
    <td>A widget for displaying images from www.fly-ted.org
 </td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="flyui/flyted/ImageWidget/Controller.html">flyui.flyted.ImageWidget.Controller</a></b></td>
    <td>A controller class for the flyted image widget internal MVC.</td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="flyui/flyted/ImageWidget/DefaultRenderer.html">flyui.flyted.ImageWidget.DefaultRenderer</a></b></td>
    <td>&nbsp;</td>
    </tr>
    
    </table>
    <hr/> 


<!-- ========== METHOD SUMMARY =========== -->

<!-- ========== END METHOD SUMMARY =========== -->


        <pre class="sourceview"><span class="comment">/**
 * <span class="attrib">@fileoverview</span>
 * This script defines a widget for fetching and displaying images from www.fly-ted.org.
 * <span class="attrib">@author</span> &lt;a href="http://purl.org/net/aliman"&gt;Alistair Miles&lt;/a&gt;, Graham Klyne, Jun Zhao
 * <span class="attrib">@version</span> $Revision:538 $ on $Date: 2008-08-27 09:08:41 +0100 (Wed, 27 Aug 2008) $ by $Author: aliman $
 * <span class="attrib">@requires</span> YAHOO.util.Connect
 * <span class="attrib">@requires</span> flyui
 * <span class="attrib">@requires</span> flyui.flyted.Service
 * <span class="attrib">@requires</span> flyui.flybase.Gene
 * TODO license terms
 */</span>
 
<span class="comment">// create a namespace if not already defined</span>
flyui.namespace(<span class="literal">"flyui.flyted"</span>);


<span class="comment">/*
 * --------------------------------------------------
 * WIDGET
 * --------------------------------------------------
 */</span>


<span class="comment">/**
 * Create a flyted image widget
 * <span class="attrib">@class</span>
 * A widget for displaying images from www.fly-ted.org
 * <span class="attrib">@constructor</span>
 * <span class="attrib">@param</span> {flyui.flyted.Service} service the service to use to fetch data
 * <span class="attrib">@param</span> {flyui.flyted.DefaultRenderer} renderer the renderer to use
 */</span>
flyui.flyted.ImageWidget = <span class="reserved">function</span>( service, renderer ) {

	try {
		var that = <span class="reserved">this</span>;
		
		<span class="comment">/** <span class="attrib">@private</span> */</span>
		<span class="reserved">this</span>._controller = null;
		
		<span class="comment">/** <span class="attrib">@private</span> */</span>
		<span class="reserved">this</span>._renderer = renderer;
		
		<span class="reserved">this</span>._model = null;
		
		<span class="reserved">this</span>._renderer = null;
    
    	<span class="reserved">this</span>._service = null;
		
		<span class="reserved">this</span>._init = <span class="reserved">function</span>() {
			<span class="comment">// create a model</span>
			var model = new flyui.mvcutils.GenericModel2();
			model.setDefinition(flyui.flyted.ImageWidget.modelDefinition);
			
			<span class="comment">// instantiate the controller</span>
			<span class="reserved">this</span>._controller = new flyui.flyted.ImageWidget.Controller(model, service, <span class="reserved">this</span>);
			
			<span class="comment">// connect the renderer to the model</span>
			renderer.connect(model);
		};
				
    	<span class="comment">// do initialisation</span>
    	<span class="reserved">this</span>._init(service, renderer);
    } catch (error) {
        throw new flyui.UnexpectedException(<span class="literal">"flyui.flyted.ImageWidget"</span>, error);
    }	
};

<span class="comment">//flyui.flyted.ImageWidget.prototype._init = function(service, renderer) {</span>
<span class="comment">//	try {</span>
<span class="comment">//		this._service = service;</span>
<span class="comment">//        this._renderer = renderer;</span>
<span class="comment">//        </span>
<span class="comment">//        // create a model</span>
<span class="comment">//        this._model = new flyui.mvcutils.GenericModel2();</span>
<span class="comment">//        this._model.setDefinition(flyui.flyted.ImageWidget.modelDefinition);</span>
<span class="comment">//        </span>
<span class="comment">//        // instantiate the controller</span>
<span class="comment">//        this._controller = new flyui.flyted.ImageWidget.Controller(this._model, service, this);</span>
<span class="comment">//        </span>
<span class="comment">//        // connect the renderer to the model</span>
<span class="comment">//        this._renderer.connect(this._model);</span>
<span class="comment">//		</span>
<span class="comment">//	}catch (error) {</span>
<span class="comment">//        throw new flyui.UnexpectedException("flyui.flyted.ImageWidget.prototype._init", error);</span>
<span class="comment">//    }	</span>
<span class="comment">//}</span>


<span class="comment">/**
 * Find images by gene names used within fly-ted
 * <span class="attrib">@param</span> {String} flytedGeneName a flyted gene name, see http://www.fly-ted.org/view/geneid/
 */</span>
flyui.flyted.ImageWidget.<span class="reserved">prototype</span>.findImagesByFlytedGeneName = <span class="reserved">function</span>( flytedGeneName ) {
	<span class="comment">// pass through to controller</span>
	try {
		<span class="reserved">this</span>._controller.findImagesByFlytedGeneName(flytedGeneName);
	}catch (error) {
        throw new flyui.UnexpectedException(<span class="literal">"flyui.flyted.ImageWidget.prototype.findImagesByFlytedGeneName"</span>, error);
    }
};


<span class="comment">/**
 * Find images by flybase gene ID, using gene name translation data
 * <span class="attrib">@param</span> {String} flybaseGeneID a flybase gene ID, e.g. FBgn123456
 */</span>
flyui.flyted.ImageWidget.<span class="reserved">prototype</span>.findImagesByFlybaseGeneID = <span class="reserved">function</span>( flybaseGeneID ) {
	try {
		<span class="comment">// pass through to controller</span>
		<span class="reserved">this</span>._controller.findImagesByFlybaseGeneID(flybaseGeneID);
	}catch (error) {
        throw new flyui.UnexpectedException(<span class="literal">"flyui.flyted.ImageWidget.prototype.findImagesByFlybaseGeneID"</span>, error);
    }
};


<span class="comment">/**
 * Find images by a gene object, translating gene names as needed.
 * <span class="attrib">@param</span> {flyui.flybase.Gene} gene
 */</span>
flyui.flyted.ImageWidget.<span class="reserved">prototype</span>.findImagesByGene = <span class="reserved">function</span>( gene ) {
	try {
		<span class="comment">// pass through to controller</span>
		<span class="reserved">this</span>._controller.findImagesByGene(gene);
	}catch (error) {
        throw new flyui.UnexpectedException(<span class="literal">"flyui.flyted.ImageWidget.prototype.findImagesByGene"</span>, error);
    }
};


<span class="comment">/*
 * --------------------------------------------------
 * CONTROLLER
 * --------------------------------------------------
 */</span>


<span class="comment">/**
 * Create a controller for a flyted image widget.
 * <span class="attrib">@class</span>
 * A controller class for the flyted image widget internal MVC.
 * <span class="attrib">@constructor</span>
 * <span class="attrib">@param</span> {flyui.mvcutils.GenericModel2} model the model to store widget state data
 * <span class="attrib">@param</span> {flyui.flyted.Service} service the service to use to fetch data
 * <span class="attrib">@param</span> {flyui.flyted.ImageWidget} widget the widget to control
 */</span>
flyui.flyted.ImageWidget.Controller = <span class="reserved">function</span>( model, service, widget ) {
	
	var that = <span class="reserved">this</span>;
	
	<span class="comment">/**
	 * <span class="attrib">@private</span>
	 */</span>
	<span class="reserved">this</span>._model = model;
	
	<span class="comment">/**
	 * <span class="attrib">@private</span>
	 */</span>
	<span class="reserved">this</span>._service = service;
	
	<span class="comment">/**
	 * <span class="attrib">@private</span>
	 */</span>
	<span class="reserved">this</span>._parent = widget;
	
	
	<span class="comment">/**
	 * <span class="attrib">@private</span>
	 * Success case callback.
	 * <span class="attrib">@param</span> {Array&lt;flyui.flyted.Image&gt;} images
	 */</span>	
	<span class="reserved">this</span>._findImagesSuccess = <span class="reserved">function</span>( images ) {
		try {
			flyui.info(<span class="literal">"request success"</span>);
		
			<span class="comment">// set the results</span>
			that._model.set(<span class="literal">"RESULTS"</span>, images);
			
			<span class="comment">// set the state</span>
			that._model.set(<span class="literal">"STATE"</span>, <span class="literal">"READY"</span>);
		}catch (error) {
        	throw new flyui.UnexpectedException(<span class="literal">"_findImagesSuccess"</span>, error);
    	}

	};
	
	
	<span class="comment">/**
	 * <span class="attrib">@private</span>
	 * Failure case callback.
	 * <span class="attrib">@param</span> {Object} response the HTTP response (YUI)
	 */</span>	
	<span class="reserved">this</span>._findImagesFailure = <span class="reserved">function</span>( response ) {
		try {
			flyui.err(<span class="literal">"request failed, status "</span>+response.status+<span class="literal">" "</span>+response.statusText);
			
			<span class="comment">// set an error message</span>
			var msg = <span class="literal">"There was an error retrieving data from FlyTED, see the logs for more info. The server may be busy or down, please try again later. If this message persists, please contact the Image Bioinformatics Research Group at bioimage@mail.ontonet.org."</span>;		
	
			that._model.set(<span class="literal">"ERRORMESSAGE"</span>, msg);
	
			<span class="comment">// set the state</span>
			that._model.set(<span class="literal">"STATE"</span>, <span class="literal">"SERVERERROR"</span>);
		}catch (error) {
        	throw new flyui.UnexpectedException(<span class="literal">"_findImagesFailure"</span>, error);
    	}		
	};
	
};


<span class="comment">/**
 * Find images by flyted gene name
 * <span class="attrib">@param</span> {String} flytedGeneName a flyted gene name, see http://www.fly-ted.org/view/geneid/
 */</span>
flyui.flyted.ImageWidget.Controller.<span class="reserved">prototype</span>.findImagesByFlytedGeneName = <span class="reserved">function</span>( flytedGeneName ) {
	try {
		<span class="comment">// pass through to private implementation</span>
		<span class="reserved">this</span>._findImagesByFlytedGeneName(flytedGeneName, <span class="reserved">this</span>._findImagesSuccess, <span class="reserved">this</span>._findImagesFailure);
	}catch (error) {
        	throw new flyui.UnexpectedException(<span class="literal">"flyui.flyted.ImageWidget.Controller.prototype.findImagesByFlytedGeneName"</span>, error);
    }
};


<span class="comment">/**
 * <span class="attrib">@private</span>
 * Implement find images by flyted gene name, allowing callback injection for testing
 * <span class="attrib">@param</span> {String} flytedGeneName a flyted gene name, see http://www.fly-ted.org/view/geneid/
 * <span class="attrib">@param</span> {Function} success success case callback
 * <span class="attrib">@param</span> {Function} failure failure case callback
 */</span>
flyui.flyted.ImageWidget.Controller.<span class="reserved">prototype</span>._findImagesByFlytedGeneName = <span class="reserved">function</span>( flytedGeneName, success, failure ) {
	try {
		flyui.info(<span class="literal">"flyui.flyted.ImageWidget.Controller._findImagesByFlytedGeneName :: request: "</span>+flytedGeneName);
		
		<span class="comment">// set the model pending</span>
		<span class="reserved">this</span>._model.set(<span class="literal">"STATE"</span>, <span class="literal">"PENDING"</span>);
		
		<span class="comment">// set the query property</span>
		<span class="reserved">this</span>._model.set(<span class="literal">"QUERY"</span>, flytedGeneName);
		
		<span class="comment">// kick off the request</span>
		<span class="reserved">this</span>._service.findImagesByFlytedProbeName(flytedGeneName, success, failure);
	}catch (error) {
        	throw new flyui.UnexpectedException(<span class="literal">"flyui.flyted.ImageWidget.Controller.prototype._findImagesByFlytedGeneName"</span>, error);
    }
};


<span class="comment">/**
 * Find images by flybase gene ID
 * <span class="attrib">@param</span> {String} flybaseGeneID a flybase gene ID, e.g. FBgn123456
 */</span>
flyui.flyted.ImageWidget.Controller.<span class="reserved">prototype</span>.findImagesByFlybaseGeneID = <span class="reserved">function</span>( flybaseGeneID ) {
	try {
		<span class="comment">// pass through to private implementation</span>
		<span class="reserved">this</span>._findImagesByFlybaseGeneID(flybaseGeneID, <span class="reserved">this</span>._findImagesSuccess, <span class="reserved">this</span>._findImagesFailure);
	}catch (error) {
        	throw new flyui.UnexpectedException(<span class="literal">"flyui.flyted.ImageWidget.Controller.prototype.findImagesByFlybaseGeneID"</span>, error);
    }
};


<span class="comment">/**
 * <span class="attrib">@private</span>
 * Implement find images by flybase gene ID, with callback injection for testing.
 * <span class="attrib">@param</span> {String} flybaseGeneID a flybase gene ID, e.g. FBgn123456
 * <span class="attrib">@param</span> {Function} success success case callback
 * <span class="attrib">@param</span> {Function} failure failure case callback
 */</span>
flyui.flyted.ImageWidget.Controller.<span class="reserved">prototype</span>._findImagesByFlybaseGeneID = <span class="reserved">function</span>( flybaseGeneID, success, failure ) {
	try {
		flyui.info(<span class="literal">"flyui.flyted.ImageWidget.Controller._findImagesByFlybaseGeneID :: request: "</span>+flybaseGeneID);
		
		<span class="comment">// set the model pending</span>
		<span class="reserved">this</span>._model.set(<span class="literal">"STATE"</span>, <span class="literal">"PENDING"</span>);
		
		<span class="comment">// set the query property</span>
		<span class="reserved">this</span>._model.set(<span class="literal">"QUERY"</span>, flybaseGeneID);
		
		<span class="comment">// kick off the request</span>
		<span class="reserved">this</span>._service.findImagesByFlybaseGeneID(flybaseGeneID, success, failure);
	}catch (error) {
        	throw new flyui.UnexpectedException(<span class="literal">"flyui.flyted.ImageWidget.Controller.prototype._findImagesByFlybaseGeneID"</span>, error);
    }
};


<span class="comment">/**
 * Find images by flybase gene object
 * <span class="attrib">@param</span> {flyui.flybase.Gene} gene 
 */</span>
flyui.flyted.ImageWidget.Controller.<span class="reserved">prototype</span>.findImagesByGene = <span class="reserved">function</span>( gene ) {
	try {
		<span class="comment">// pass through to private implementation</span>
		<span class="reserved">this</span>._findImagesByGene(gene, <span class="reserved">this</span>._findImagesSuccess, <span class="reserved">this</span>._findImagesFailure);
	}catch (error) {
        	throw new flyui.UnexpectedException(<span class="literal">"flyui.flyted.ImageWidget.Controller.prototype.findImagesByGene"</span>, error);
    }
};


<span class="comment">/**
 * <span class="attrib">@private</span>
 * Implement find images by flybase gene object, with callback injection to support testing
 * <span class="attrib">@param</span> {flyui.flybase.Gene} gene 
 * <span class="attrib">@param</span> {Function} success success case callback
 * <span class="attrib">@param</span> {Function} failure failure case callback
 */</span>
flyui.flyted.ImageWidget.Controller.<span class="reserved">prototype</span>._findImagesByGene = <span class="reserved">function</span>( gene, success, failure ) {
	try {
		flyui.info(<span class="literal">"flyui.flyted.ImageWidget.Controller._findImagesByGene :: request: "</span>+gene.flybaseID);
	
		<span class="comment">// set the model pending</span>
		<span class="reserved">this</span>._model.set(<span class="literal">"STATE"</span>, <span class="literal">"PENDING"</span>);
		
		<span class="comment">// set the query property</span>
		<span class="reserved">this</span>._model.set(<span class="literal">"QUERY"</span>, gene);
		
		<span class="comment">// kick off the request</span>
		<span class="reserved">this</span>._service.findImagesByFlybaseGeneID(gene.flybaseID, success, failure);
	}catch (error) {
        	throw new flyui.UnexpectedException(<span class="literal">"flyui.flyted.ImageWidget.Controller.prototype._findImagesByGene"</span>, error);
    }
};


<span class="comment">/*
 * --------------------------------------------------
 * MODEL DEFINITION
 * --------------------------------------------------
 */</span>


<span class="comment">/**
 * Definition of flyted imagewidget model.
 */</span>
flyui.flyted.ImageWidget.modelDefinition = {

	properties : [ <span class="literal">"STATE"</span>, <span class="literal">"RESULTS"</span>, <span class="literal">"QUERY"</span>, <span class="literal">"ERRORMESSAGE"</span> ],
	
	values : {
		<span class="literal">"STATE"</span> : [ <span class="literal">"PENDING"</span>, <span class="literal">"READY"</span>, <span class="literal">"SERVERERROR"</span>, <span class="literal">"UNEXPECTEDERROR"</span> ]
	},
	
	initialize : <span class="reserved">function</span>( data ) {
		data[<span class="literal">"STATE"</span>] = <span class="literal">"READY"</span>;
		data[<span class="literal">"RESULTS"</span>] = null;
		data[<span class="literal">"QUERY"</span>] = null;
		data[<span class="literal">"ERRORMESSAGE"</span>] = null;
	}

};


<span class="comment">/*
 * --------------------------------------------------
 * DEFAULT RENDERER
 * --------------------------------------------------
 */</span>


<span class="comment">/**
 * TODO doc me
 */</span>
flyui.flyted.ImageWidget.DefaultRenderer = <span class="reserved">function</span>() {};


<span class="comment">/**
 * TODO doc me
 */</span>
flyui.flyted.ImageWidget.DefaultRenderer.<span class="reserved">prototype</span>.setCanvas = <span class="reserved">function</span>( canvas ) {
    try {
	    <span class="reserved">this</span>._canvas = canvas;
	    <span class="reserved">this</span>._initCanvas();
	}catch (error) {
        	throw new flyui.UnexpectedException(<span class="literal">"flyui.flyted.ImageWidget.DefaultRenderer.prototype.setCanvas"</span>, error);
    }
};


<span class="comment">/**
 * <span class="attrib">@private</span>
 * TODO doc me
 */</span>
flyui.flyted.ImageWidget.DefaultRenderer.<span class="reserved">prototype</span>._initCanvas = <span class="reserved">function</span>() {
	try {
	    <span class="comment">// set up the pending pane</span>
        <span class="reserved">this</span>._pendingPane = document.createElement(<span class="literal">"p"</span>);
        <span class="reserved">this</span>._pendingPane.innerHTML = <span class="literal">"pending..."</span>;
        <span class="reserved">this</span>._canvas.appendChild(<span class="reserved">this</span>._pendingPane);
        YAHOO.util.Dom.addClass(<span class="reserved">this</span>._pendingPane, <span class="literal">"pendingPane"</span>);
        flyui.mvcutils.hide(<span class="reserved">this</span>._pendingPane);
	    
	    <span class="comment">// set up the message pane</span>
	    <span class="reserved">this</span>._messagePane = document.createElement(<span class="literal">"div"</span>);
	    <span class="reserved">this</span>._messagePane.innerHTML = <span class="literal">"this should never be displayed"</span>;
	    <span class="reserved">this</span>._canvas.appendChild(<span class="reserved">this</span>._messagePane);
	    YAHOO.util.Dom.addClass(<span class="reserved">this</span>._messagePane, <span class="literal">"messagePane"</span>);
	    flyui.mvcutils.hide(<span class="reserved">this</span>._messagePane);
	    
	    <span class="comment">// setup results summary pane</span>
	    <span class="reserved">this</span>._resultsSummaryPane = document.createElement(<span class="literal">"p"</span>);
	    <span class="reserved">this</span>._canvas.appendChild(<span class="reserved">this</span>._resultsSummaryPane);
	    YAHOO.util.Dom.addClass(<span class="reserved">this</span>._resultsSummaryPane, <span class="literal">"resultsSummaryPane"</span>);
	    flyui.mvcutils.hide(<span class="reserved">this</span>._resultsSummaryPane);
	    
	    <span class="comment">// setup results pane</span>
	    <span class="reserved">this</span>._resultsPane = document.createElement(<span class="literal">"div"</span>);
	    <span class="reserved">this</span>._canvas.appendChild(<span class="reserved">this</span>._resultsPane);
	    YAHOO.util.Dom.addClass(<span class="reserved">this</span>._resultsPane, <span class="literal">"resultsPane"</span>);
	    flyui.mvcutils.hide(<span class="reserved">this</span>._resultsPane);
	}catch (error) {
        	throw new flyui.UnexpectedException(<span class="literal">"flyui.flyted.ImageWidget.DefaultRenderer.prototype._initCanvas"</span>, error);
    }
};

<span class="comment">/**
 * <span class="attrib">@private</span>
 */</span>
flyui.flyted.ImageWidget.DefaultRenderer.<span class="reserved">prototype</span>._canvas = null;

<span class="comment">/**
 * <span class="attrib">@private</span>
 */</span>
flyui.flyted.ImageWidget.DefaultRenderer.<span class="reserved">prototype</span>._pendingPane = null;

<span class="comment">/**
 * <span class="attrib">@private</span>
 */</span>
flyui.flyted.ImageWidget.DefaultRenderer.<span class="reserved">prototype</span>._resultsPane = null;

<span class="comment">/**
 * <span class="attrib">@private</span>
 */</span>
flyui.flyted.ImageWidget.DefaultRenderer.<span class="reserved">prototype</span>._resultsSummaryPane = null;

<span class="comment">/**
 * <span class="attrib">@private</span>
 */</span>
flyui.flyted.ImageWidget.DefaultRenderer.<span class="reserved">prototype</span>._messagePane = null;

<span class="comment">/**
 * <span class="attrib">@private</span>
 * Main callback function for model changes.
 * <span class="attrib">@param</span> {String} type the name of the model property changed
 * <span class="attrib">@param</span> {Array} args the callback args
 * <span class="attrib">@param</span> {flyui.genefinder.DefaultRenderer} self a self reference, to work around callback issues
 */</span>
flyui.flyted.ImageWidget.DefaultRenderer.<span class="reserved">prototype</span>._onModelChanged = <span class="reserved">function</span>(type, args, self) {
    try {
	    var handlers = {
	        <span class="literal">"STATE"</span>:<span class="literal">"_onStateChanged"</span>,
	        <span class="literal">"QUERY"</span>:<span class="literal">"_onQueryChanged"</span>,
	        <span class="literal">"RESULTS"</span>:<span class="literal">"_onResultsChanged"</span>,
	        <span class="literal">"ERRORMESSAGE"</span>:<span class="literal">"_onErrorMessageChanged"</span>
	    };
	    var handler = handlers[type];
	    flyui.debug(<span class="literal">"handler: "</span>+handler);
	    <span class="comment">// call the handler</span>
	    self[handler](args[0], args[1]);
	}catch (error) {
        	throw new flyui.UnexpectedException(<span class="literal">"flyui.flyted.ImageWidget.DefaultRenderer.prototype._onModelChanged"</span>, error);
    }
};


<span class="comment">/**
 * <span class="attrib">@private</span>
 * TODO doc me
 */</span>
flyui.flyted.ImageWidget.DefaultRenderer.<span class="reserved">prototype</span>._onStateChanged = <span class="reserved">function</span>( from, to ) {
    try {
	    <span class="reserved">if</span> ( to == <span class="literal">"PENDING"</span> ) {
		    flyui.mvcutils.show(<span class="reserved">this</span>._pendingPane);
		    flyui.mvcutils.hide(<span class="reserved">this</span>._messagePane);
		    flyui.mvcutils.hide(<span class="reserved">this</span>._resultsSummaryPane);
		    flyui.mvcutils.hide(<span class="reserved">this</span>._resultsPane);
		} 
		<span class="reserved">else</span> <span class="reserved">if</span> (to == <span class="literal">"READY"</span>) {
		    flyui.mvcutils.hide(<span class="reserved">this</span>._pendingPane);
		    flyui.mvcutils.hide(<span class="reserved">this</span>._messagePane);
		    flyui.mvcutils.show(<span class="reserved">this</span>._resultsSummaryPane);
		    flyui.mvcutils.show(<span class="reserved">this</span>._resultsPane);     
		}
		<span class="reserved">else</span> <span class="reserved">if</span> ( to == <span class="literal">"SERVERERROR"</span> || to == <span class="literal">"UNEXPECTEDERROR"</span> ) {
		    flyui.mvcutils.hide(<span class="reserved">this</span>._pendingPane);
		    flyui.mvcutils.show(<span class="reserved">this</span>._messagePane);
		    flyui.mvcutils.hide(<span class="reserved">this</span>._resultsSummaryPane);
		    flyui.mvcutils.hide(<span class="reserved">this</span>._resultsPane);         
		} 
		<span class="reserved">else</span> {
		    <span class="comment">// this should never happen</span>
	    	throw {name:<span class="literal">"flyui.flyted.ImageWidget.UnexpectedStateError"</span>, message:<span class="literal">"Invalid state: "</span>+newState};
		}
	}catch (error) {
        	throw new flyui.UnexpectedException(<span class="literal">"flyui.flyted.ImageWidget.DefaultRenderer.prototype._onStateChanged"</span>, error);
    }
};


<span class="comment">/**
 * <span class="attrib">@private</span>
 * TODO doc me
 */</span>
flyui.flyted.ImageWidget.DefaultRenderer.<span class="reserved">prototype</span>._onQueryChanged = <span class="reserved">function</span>( from, to ) {
	try {
    	<span class="comment">// store query</span>
    	<span class="reserved">this</span>._query = to;
    }catch (error) {
        	throw new flyui.UnexpectedException(<span class="literal">"flyui.flyted.ImageWidget.DefaultRenderer.prototype._onQueryChanged"</span>, error);
    }
};


<span class="comment">/**
 * <span class="attrib">@private</span>
 * TODO doc me
 */</span>
flyui.flyted.ImageWidget.DefaultRenderer.<span class="reserved">prototype</span>._onResultsChanged = <span class="reserved">function</span>( from, to ) {
	
	try {
		var probes = [];
		<span class="reserved">if</span> (to.length &gt; 0) {
			probes = new Array();
			<span class="reserved">for</span> (var i in to){
				var labels = to[i].probe.probeLabels;
				<span class="reserved">for</span> (var l in labels){
					flyui.util.appendIfNotMember(probes, labels[l]);
				}
			}
		}
		
	    <span class="comment">// render the results summary</span>
	    flyui.debug(<span class="literal">"render the results summary"</span>);
	    <span class="reserved">this</span>._renderResultsSummary(<span class="reserved">this</span>._query, to.length, probes);
	    
	    <span class="reserved">if</span> (to.length &gt; 0) {
	        flyui.debug(<span class="literal">"render the results "</span>+to.length);
	        
	        <span class="comment">// set the content</span>
	        <span class="reserved">this</span>._resultsPane.innerHTML = <span class="reserved">this</span>._imagesToDivHTML(to); 
	
	    }
	    <span class="reserved">else</span> {
	        flyui.info(<span class="literal">"empty results, empty results pane"</span>);
	        <span class="reserved">this</span>._resultsPane.innerHTML = <span class="literal">""</span>;
	    }
	}catch (error) {
        	throw new flyui.UnexpectedException(<span class="literal">"flyui.flyted.ImageWidget.DefaultRenderer.prototype._onResultsChanged"</span>, error);
    }

};
  
  
<span class="comment">/**
 * <span class="attrib">@private</span>
 */</span>
flyui.flyted.ImageWidget.DefaultRenderer.<span class="reserved">prototype</span>._onErrorMessageChanged = <span class="reserved">function</span>( from, to) {
    try {
    	<span class="reserved">this</span>._messagePane.innerHTML = to;
    }catch (error) {
        	throw new flyui.UnexpectedException(<span class="literal">"flyui.flyted.ImageWidget.DefaultRenderer.prototype._onErrorMessageChanged"</span>, error);
    }
};


<span class="comment">/**
 * TODO doc me
 */</span>
flyui.flyted.ImageWidget.DefaultRenderer.<span class="reserved">prototype</span>.connect = <span class="reserved">function</span>( model ) {
	try {
    	model.subscribeAll(<span class="reserved">this</span>._onModelChanged, <span class="reserved">this</span>);
    }catch (error) {
        	throw new flyui.UnexpectedException(<span class="literal">"flyui.flyted.ImageWidget.DefaultRenderer.prototype.connect"</span>, error);
    }

};


<span class="comment">/**
 * <span class="attrib">@private</span>
 * TODO doc me
 */</span>
flyui.flyted.ImageWidget.DefaultRenderer.<span class="reserved">prototype</span>._renderResultsSummary = <span class="reserved">function</span>( query, count, probeLabels ) {
    var _context = <span class="literal">"flyui.flyted.ImageWidget.DefaultRenderer.prototype._renderResultsSummary"</span>;
	try {
		flyui.debug(<span class="literal">"building results summary content"</span>, _context);
	    var content = <span class="literal">"showing &lt;span&gt;"</span>;
	    content += count;
	    content += <span class="literal">"&lt;/span&gt; matching image"</span>;
	    content += (count == 0 || count &gt; 1) ? <span class="literal">"s "</span> : <span class="literal">" "</span>;
	    content += <span class="literal">"from &lt;a href='http://www.fly-ted.org'&gt;www.fly-ted.org&lt;/a&gt; for "</span>;
	        
	    <span class="reserved">if</span> (query instanceof flyui.flybase.Gene) {
	    	flyui.debug(<span class="literal">"a flybaseid in the query: "</span> +query, _context);
	        content += <span class="literal">"gene &lt;strong&gt;"</span>+query.symbols.join(<span class="literal">" / "</span>)+<span class="literal">"&lt;/strong&gt;"</span>;
	        
	        <span class="comment">//var ftnames = flyui.flyted.GeneNameMappings.flybaseToFlyted[query.flybaseID];</span>
	        
	        var ftnames = probeLabels;
	        
	        flyui.debug(<span class="literal">"the flyted probe names "</span> + ftnames.length, _context);
	        
	        <span class="reserved">if</span> (ftnames.length == 1) {
                content += <span class="literal">" [&lt;a href='http://www.fly-ted.org/view/geneid/"</span>+ftnames[0]+<span class="literal">".html'&gt;Fly-TED gene report&lt;/a&gt;]..."</span>;	            
	        } <span class="reserved">else</span> <span class="reserved">if</span> (ftnames.length &gt; 1) {
                content += <span class="literal">" [Fly-TED gene report: "</span>;
                <span class="reserved">for</span> (var i=0; i&lt;ftnames.length; i++) {
                    content += <span class="literal">"&lt;strong&gt;&lt;a href='http://www.fly-ted.org/view/geneid/"</span>+ftnames[i]+<span class="literal">".html'&gt;"</span>+ftnames[i]+<span class="literal">"&lt;/a&gt;&lt;/strong&gt;"</span>;
                    <span class="reserved">if</span> (i &lt; ftnames.length-1) content += <span class="literal">" / "</span>;
                }
                <span class="reserved">if</span> (ftnames.length &gt; 1) {
                    content += <span class="literal">" (N.B. both links report data on the same probe)"</span>;
                }
                content += <span class="literal">"]..."</span>;
	        }
	        
<span class="comment">//	        if (typeof ftnames == "undefined" || !ftnames || ftnames.length == 0) {</span>
<span class="comment">//	            content += " (no mapping found to FlyTED gene names";</span>
<span class="comment">//	        }</span>
<span class="comment">//	        else if (ftnames.length == 1) {</span>
<span class="comment">//	            content += " (mapped to FlyTED gene name &lt;strong&gt;&lt;a href='http://www.fly-ted.org/view/geneid/"+ftnames[0]+".html'&gt;"+ftnames[0]+"&lt;/a&gt;&lt;/strong&gt;";         </span>
<span class="comment">//	        }</span>
<span class="comment">//	        else if (ftnames.length &gt; 1) {</span>
<span class="comment">//	            content += " (mapped to FlyTED gene names ";</span>
<span class="comment">//	            for (var i=0; i&lt;ftnames.length; i++) {</span>
<span class="comment">//	                content += "&lt;strong&gt;&lt;a href='http://www.fly-ted.org/view/geneid/"+ftnames[i]+".html'&gt;"+ftnames[i]+"&lt;/a&gt;&lt;/strong&gt;";</span>
<span class="comment">//	                if (i &lt; ftnames.length-1) content += ", ";</span>
<span class="comment">//	            }</span>
<span class="comment">//	        }       </span>
<span class="comment">//	        content += ", N.B. gene name mappings may contain errors, check source data carefully)";</span>
	    } <span class="reserved">else</span> {
	    	flyui.debug(<span class="literal">"not a flybaseid in the query :"</span>+ query, _context);
	        content +=  <span class="literal">"query &lt;span&gt;'"</span>+query+<span class="literal">"'&lt;/span&gt;"</span>;
	    }
	    <span class="reserved">this</span>._resultsSummaryPane.innerHTML = content;
	} catch (error) {
        	throw new flyui.UnexpectedException(_context, error);
    }
};

<span class="comment">/**
 * <span class="attrib">@private</span>
 * TODO doc me
 */</span>
flyui.flyted.ImageWidget.DefaultRenderer.<span class="reserved">prototype</span>._imagesToDivHTML = <span class="reserved">function</span>( images ) {

    try {
	    <span class="comment">// build the divs</span>
	    
	    flyui.debug(<span class="literal">"build div content for images "</span>+images.length);
	    var content = <span class="literal">""</span>;
	    <span class="reserved">for</span> ( var i in images ) {
	        
	        content += <span class="reserved">this</span>._imageToDivHTML(images[i]);
	        flyui.debug(<span class="literal">"Generate the img div"</span> + content); 
	    }
	    
	    <span class="reserved">return</span> content;
	}catch (error) {
        	throw new flyui.UnexpectedException(<span class="literal">"flyui.flyted.ImageWidget.DefaultRenderer.prototype._imagesToDivHTML"</span>, error);
    }
};


<span class="comment">/**
 * <span class="attrib">@private</span>
 * TODO doc me
 */</span>
flyui.flyted.ImageWidget.DefaultRenderer.<span class="reserved">prototype</span>._imageToDivHTML = <span class="reserved">function</span>( image ) {
  	try {
	    flyui.debug(<span class="literal">"build content for image "</span>+image.caption);
	    
	    var content =   <span class="literal">"&lt;div class=\"</span>result\<span class="literal">"&gt;"</span>;
	    content +=          <span class="literal">"&lt;p&gt;&lt;a href=\"</span><span class="literal">" + image.flytedURL + "</span>\<span class="literal">"&gt;"</span>;
	    content +=              <span class="literal">"&lt;img src=\"</span><span class="literal">" + image.thumbnailURL + "</span>\<span class="literal">" alt=\"</span><span class="reserved">this</span> is an image\<span class="literal">"&gt;"</span>;
	    content +=          <span class="literal">"&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;"</span>; 
	    content +=          <span class="literal">"&lt;p class=\"</span>caption\<span class="literal">"&gt;"</span>+image.caption+<span class="literal">"&lt;/p&gt;"</span>
	    content +=      <span class="literal">"&lt;/div&gt;"</span>;
	    
	    <span class="reserved">return</span> content;
	}catch (error) {
        	throw new flyui.UnexpectedException(<span class="literal">"flyui.flyted.ImageWidget.DefaultRenderer.prototype._imageToDivHTML"</span>, error);
    }
};

</pre>
	<hr>



<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
<b>FlyUI</b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<font size="-1">

</font>
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Tue Dec  9 11:08:18 2008</div>
</body>
</html>
